public class Solution {
    public int longestOnes(int[] nums, int k) {
        int n = nums.length;
        int res = 0;
        int max = 0;
        return max;
    }

    public static void main(String[] args) {
        int[] nums = {1,1,1,0,0,1,1,1,1};
        System.out.println(MaxOne(nums));
    }

    public static int MaxOne(int[] nums){
        int n = nums.length;
        int left = 0;
        int right = 0;
        int max = 0;
        while (right < n){
        if (nums[right] == 1) {
            right++;
        }else {
            int sum = right - left;
            max = Math.max(sum,max);
        }
        }
        return max;
    }


}
